import type { ISite } from '~/server/models/site.model';

export const useSiteConfigStore = defineStore('siteConfig', () => {
	const config = ref<ISite>({
		_id: '',
		title: '',
		description: '',
		keywords: '',
		globalCss: '',
		globalJs: '',
		about: '',
		isUse: true,
		createdAt: '',
		updatedAt: '',
	});

	// 获取配置
	const getConfig = async (): Promise<void> => {
		const res: any = await $fetch('/api/client/site/config');
		config.value = {
			...res.data,
			__v: undefined,
		};
	};

	return { config, getConfig };
});
